# -*- coding: UTF-8 -*-

import sys

from encodings import mbcs   


import os
from os.path import walk, join, normpath
from os import chdir, remove

sys.path[0].decode(sys.getfilesystemencoding())

def scan(arg, dirname, names):
  for file in names:
    print dirname, file
    
    if file[-1:]=="~" or file[-4:]==".pyc":
      files = normpath(join(dirname,file))
      chdir(dirname)
      print "deleting", files
      remove(file)
      print "done!"
    
    
if __name__== "__main__":
  path = "D:\\java_projects\\ideagen\\generator" 
  chdir(path)
  #print os.getcwd()
  #print path
  walk(path, scan, 0)
